/*
 * WeeklyRewardResource.h
 *
 *  Created on: 2013. 9. 6.
 *      Author: mega@gamevil.com
 */

#ifndef WEEKLYREWARDRESOURCE_H_
#define WEEKLYREWARDRESOURCE_H_

#include <map>

namespace ProjectZ { namespace NResource {

class WeeklyRewardData
{
public:
	struct Key
	{
		Key() : type(0), sub_type(0) {}
		Key(int rType, int rSubType) : type(rType), sub_type(rSubType) {}

		int type;
		int sub_type;

		bool operator == (const Key & rSide) const
		{
			if (this->type == rSide.type && this->sub_type == rSide.sub_type)
				return true;

			return false;
		}

		bool operator < (const Key & rSide) const
		{
			if (this->type < rSide.type)
			{
				return true;
			}
			else if (this->type == rSide.type)
			{
				if (this->sub_type < rSide.sub_type)
					return true;
			}

			return false;
		}
	};

public:
	struct Flyweight
	{
		int _TYPE;
		int _MIN;
		int _MAX;
		int _REWARD_SHEET_TYPE;
		int _REWARD_TID;
		int _VALUE;
	};

public:
	WeeklyRewardData() {};
	virtual ~WeeklyRewardData();

	bool LoadResource(int company, int saleCode);
//	Flyweight * GetFly(Key & clsKey);
	Flyweight * GetFly(int key);
//	typedef std::map<Key, Flyweight *>	DATATREE;
	typedef std::map<int, Flyweight *>	DATATREE;
	DATATREE & GetFlyTree() { return clsFlyTree; }

private:
	void Clear();

private:
	DATATREE	clsFlyTree;
};


class WeeklyRewardResource
{
public:
	WeeklyRewardResource();
	virtual ~WeeklyRewardResource();

	bool LoadResource();
	WeeklyRewardData * GetFly(User * pUser);
//	WeeklyRewardData::Flyweight * FindFly(int company, int saleCode, WeeklyRewardData::Key & clsKey);
	WeeklyRewardData::Flyweight * FindFly(User * pUser, int key);

private:
	WeeklyRewardData * pWeekRewardAndroid;
	WeeklyRewardData * pWeekRewardIOS;
};

} /* NResource */ } /* ProjectZ */

#endif /* WEEKLYREWARDRESOURCE_H_ */
